package model.visibility;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import model.map.GameTile;
import model.mapping.PlayableMapping;
import model.playable.structure.Structure;
import model.playable.unit.Unit;
import model.playable.unit.Vehicle;
import model.playable.unit.Worker;

public class GetVisibleTilesFunction implements PlayableFunction
{
	private PlayableMapping mapping = PlayableMapping.getPlayableMapping();
	Set<GameTile> visibleTiles;
	
	public GetVisibleTilesFunction()
	{
		visibleTiles = new HashSet<GameTile>();
	}
	
	public void executeOnStructure(Structure s)
	{
		visibleTiles.addAll(mapping.getTilesAroundStructure(s, s.getVisibilityRadius()));

	}

	public void executeOnUnit(Unit u)
	{
		visibleTiles.addAll(mapping.getTilesAroundUnit(u, u.getVisibilityRadius()));

	}

	public void executeOnWorker(Worker w)
	{
		visibleTiles.addAll(mapping.getTilesAroundWorker(w, w.getVisibilityRadius()));

	}
	
	public void executeOnVehicle(Vehicle v)
	{
		visibleTiles.addAll(mapping.getTilesAroundVehicle(v, v.getVisibilityRadius()));
	}

	public List<GameTile> getVisibleTiles()
	{
		List<GameTile> tileList = new LinkedList<GameTile>(visibleTiles);
		return tileList;
	}
}
